{% extends 'base.html' %}

{% load i18n %}
{% load custom_url_tags %}
{% load custom_formatting %}

{% block title %}
{% if kind == "training" %}
{% blocktrans with network_name=network.name %} KataGo - Training Games for {{network_name}} {% endblocktrans %}
{% else %}
{% blocktrans with network_name=network.name %} KataGo - Rating Games for {{network_name}} {% endblocktrans %}
{% endif %}
{% endblock %}

{% block content %}

{% if kind == "training" %}
<h1 class="title">{% blocktrans with network_name=network.name %} Training Games for {{network_name}} {% endblocktrans %}</h1>
{% else %}
<h1 class="title">{% blocktrans with network_name=network.name %} Rating Games for {{network_name}} {% endblocktrans %}</h1>
{% endif %}

{% include 'pagination.html' with other_get_params='' page_obj=page_obj %}

{% if kind == "rating" %}
<table class="table">
  <tr>
    <th> {% trans "Game ID" %} </th>
    <th> {% trans "Uploaded At" %} </th>
    <th> {% trans "Submitted By" %} </th>
    <th> {% trans "Own Color" %} </th>
    <th> {% trans "Opponent" %} </th>
    <th> {% trans "BSizeX" %} </th>
    <th> {% trans "BSizeY" %} </th>
    <th> {% trans "Komi" %} </th>
    <th> {% trans "Length" %} </th>
    <th> {% trans "Result" %} </th>
    <th> {% trans "SGF" %} </th>
    <th> {% trans "View" %} </th>
  </tr>
{% for game in page_obj %}
  <tr>
    <td> {{ game.id }} </td>
    <td> {{ game.created_at|isotimestr }} </td>
    <td> {{ game.submitted_by }} </td>
    {% if game.black_network.name == network.name %}
    <td> Black </td>
    <td> {{ game.white_network.name|chop_network_run_name:run.name }} </td>
    {% else %}
    <td> White </td>
    <td> {{ game.black_network.name|chop_network_run_name:run.name }} </td>
    {% endif %}
    <td> {{ game.board_size_x }} </td>
    <td> {{ game.board_size_y }} </td>
    <td> {{ game.komi }} </td>
    <td> {{ game.game_length }} </td>
    <td class="{{ game|game_winner_class:network }}"> {{ game.result_text }} </td>
    <td> <a href="{{ game.sgf_file.url }}">[{% trans "SGF" %}]</a> </td>
    <td> <a href="{% sgfplayer kind game.id %}">[{% trans "View" %}]</a> </td>
  </tr>
{% endfor %}
</table>
{% else %}
<table class="table">
  <tr>
    <th> {% trans "Game ID" %} </th>
    <th> {% trans "Uploaded At" %} </th>
    <th> {% trans "Submitted By" %} </th>
    <th> {% trans "BSizeX" %} </th>
    <th> {% trans "BSizeY" %} </th>
    <th> {% trans "Handicap" %} </th>
    <th> {% trans "Komi" %} </th>
    <th> {% trans "GameType" %} </th>
    <th> {% trans "Length" %} </th>
    <th> {% trans "Result" %} </th>
    <th> {% trans "SGF" %} </th>
    <th> {% trans "View" %} </th>
  </tr>
{% for game in page_obj %}
  <tr>
    <td> {{ game.id }} </td>
    <td> {{ game.created_at|isotimestr }} </td>
    <td> {{ game.submitted_by }} </td>
    <td> {{ game.board_size_x }} </td>
    <td> {{ game.board_size_y }} </td>
    <td> {{ game.handicap }} </td>
    <td> {{ game.komi }} </td>
    <td> {{ game.gametype|underscores_to_spaces }} </td>
    <td> {{ game.game_length }} </td>
    <td> {{ game.result_text }} </td>
    <td> <a href="{{ game.sgf_file.url }}">[{% trans "SGF" %}]</a> </td>
    <td> <a href="{% sgfplayer kind game.id %}">[{% trans "View" %}]</a> </td>
  </tr>
{% endfor %}
</table>
{% endif %}

{% include 'pagination.html' with other_get_params='' page_obj=page_obj %}

{% endblock content %}
